package security;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.GregorianCalendar;

public class DateValide {
	public static boolean estValide(String s) {
		final DateFormat DEFAULT_FORMATTER;
		DEFAULT_FORMATTER = new SimpleDateFormat("dd/MM/yyyy");
		DEFAULT_FORMATTER.setLenient(false);
		try {
			DEFAULT_FORMATTER.parse(s);
		} catch (ParseException e) {
			return false;
		}

		return true;
	}

	public static boolean afterNow(int annee, int mois) {
		GregorianCalendar now = new GregorianCalendar();
		GregorianCalendar dateTest = new GregorianCalendar();
		dateTest.set(annee, mois, dateTest.getActualMaximum(GregorianCalendar.DAY_OF_MONTH));
		if (dateTest.after(now)) {
			return true;
		} else {
			return false;
		}
	}
}
